#!/usr/bin/perl
##
## Copyright (c) 1999-2000 Internet Images Srl
##                    Massimiliano Masserelli
##
## Synopsys: 
##   classdoctpl.pl < classdeclaration.inc
##
## Output:
##   A file for every class defined in classdeclaration.inc, named after
##   each class with ".sgml" extension containing a workable template
##   to start with.
##   A line to stdout for every class method and instance, just to tell
##   you what's going on.
##
## Bugs/Features:
##   Instances which are initialized in declaration with defaults, are 
##   reported as such in output template[s]. This DOES NOT follow
##   phplib documentation style, but may be an useful reminder when
##   editing the template.
##
## WARNING!!
##   This script is a VERY QUICK HACK(tm). If you follow phplib codestyle
##   should work. It works for me(tm), YMMV.
##
## $Id: classdoctpl.pl,v 1.2 2000/07/12 18:22:31 kk Exp $
##

$pcount = 0;
$cclass = "";

while (<>) {
  chop;
  while (?\}?) {
    $pcount --;
  }
  reset;
  if ($pcount == 0) {
    if (/class\s+(\w+)\s+{/) {
      # Beginning of a class
      $cclass = $1;
      push(@classes, $cclass);
      @{$variables{$cclass}} = ();
      @{$methods{$cclass}} = ();
    }
  } elsif ($pcount == 1) {
#    if (/function\s+(\w+)\s*\(([a-zA-Z ,\$=_]*)\)\s*\{/) {
    if (/function\s+(\w+)\s*\((.*)\)\s*\{/) {
      push(@{$methods{$cclass}}, sprintf("%s(%s)", $1, $2));
      print $cclass . "->" . $1 . "(" . $2 